<template>
	<view class="container">
		<view class="box">
			<view class="f-item">
				<view class="content" @click="toUrl('/pagesMine/mine/BindPhone/BindPhone')">
					<view class="label"> 更换手机号 </view>
					<view class="right bindPhone">
						<text v-if="false">未绑定</text>
						<text v-else class="red">已绑定</text>
						<image :src="$img_path('/mine/r_img.png')" mode="widthFix"></image>
					</view>
				</view>
			</view>
		</view>
		<view class="box">
			<view class="f-item">
				<view class="content" @click="openAgreementPopup('用户协议')">
					<view class="label"> 用户协议 </view>
					<view class="right">
						<image :src="$img_path('/mine/r_img.png')" mode="widthFix"></image>
					</view>
				</view>
			</view>
			<view class="f-item">
				<view class="content" @click="openAgreementPopup('隐私协议')">
					<view class="label"> 隐私协议 </view>
					<view class="right">
						<image :src="$img_path('/mine/r_img.png')" mode="widthFix"></image>
					</view>
				</view>
			</view>
		</view>
		<view class="box">
			<view class="f-item">
				<view class="content" @click="openAgreementPopup('个人信息收集清单')">
					<view class="label"> 个人信息收集清单 </view>
					<view class="right">
						<image :src="$img_path('/mine/r_img.png')" mode="widthFix"></image>
					</view>
				</view>
			</view>
			<view class="f-item">
				<view class="content" @click="openAgreementPopup('与第三方共享个人信息清单')">
					<view class="label"> 与第三方共享个人信息清单 </view>
					<view class="right">
						<image :src="$img_path('/mine/r_img.png')" mode="widthFix"></image>
					</view>
				</view>
			</view>

			<view class="f-item">
				<view class="content" @click="openAgreementPopup('协议指引与说明')">
					<view class="label"> 协议指引与说明 </view>
					<view class="right">
						<image :src="$img_path('/mine/r_img.png')" mode="widthFix"></image>
					</view>
				</view>
			</view>
		</view>

		<view class="box">
			<view class="f-item">
				<view class="content">
					<view class="label"> 清除缓存 </view>
					<view class="right">
						<text>10MB</text>
					</view>
				</view>
			</view>
			<view class="f-item">
				<view class="content" @click="toUrl('/pagesMine/system/aboutUs')">
					<view class="label"> 关于我们 </view>
					<view class="right">
						<image :src="$img_path('/mine/r_img.png')" mode="widthFix"></image>
					</view>
				</view>
			</view>

			<view class="f-item">
				<view class="content" @click="toUrl('/pagesMine/system/clearAccount/index')">
					<view class="label"> 注销账号 </view>
					<view class="right">
						<image :src="$img_path('/mine/r_img.png')" mode="widthFix"></image>
					</view>
				</view>
				<view class="tip"> 提交申请，删除所有数据，永久注销账号 </view>
			</view>
		</view>

		<view class="btn">
			<button @click="quit()">退出当前账号</button>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {};
		},
		methods: {
			// 打开协议弹窗
			openAgreementPopup(type) {
				console.log('打开协议弹窗', type)
				uni.navigateTo({
					url: "/pagesRegion/servicePersonnelReview/agreement?type=" + type,
				});
			},
			toUrl(url) {
				uni.navigateTo({
					url,
				});
			},
			// 退出当前账号
			quit() {
				uni.showModal({
					title: "温馨提示",
					content: "退出当前账号后，您的账号信息将被清除,请谨慎处理!是否继续退出当前账号?",
					success: (res) => {
						if (res.confirm) {
							uni.clearStorageSync();
							uni.reLaunch({
								url: "/pages/login/login",
							});
						}
					},
				});
			},
		},
	};
</script>

<style lang="scss" scoped>
	.container {
		padding-bottom: constant(safe-area-inset-bottom);
		padding-bottom: env(safe-area-inset-bottom);

		.box {
			width: 100%;
			background-color: #ffffff;
			margin-bottom: 20rpx;
			padding: 0 30rpx;
			box-sizing: border-box;

			.f-item {
				width: 100%;
				padding: 36rpx 0 38rpx;

				&:not(:first-child) {
					border-top: 2rpx solid #f9f9f9;
				}

				.content {
					display: flex;
					align-items: center;
					justify-content: space-between;

					.label {
						font-weight: bold;
						font-size: 32rpx;
						color: #000000;
						line-height: 44rpx;
					}

					.right {
						display: flex;
						align-items: center;

						text {
							font-weight: 400;
							font-size: 32rpx;
							color: #8d8d8d;
							line-height: 44rpx;
						}

						&.bindPhone {
							text.red {
								color: #e72a2a;
							}
						}

						image {
							width: 16rpx;
							height: 29rpx;
							margin-left: 22rpx;
						}
					}
				}

				&>.tip {
					font-weight: 400;
					font-size: 24rpx;
					color: #8d8d8d;
					line-height: 34rpx;
					margin-top: 16rpx;
				}
			}
		}

		.btn {
			padding: 0 22rpx 20rpx;
			box-sizing: border-box;
			margin-top: 110rpx;

			button {
				width: 100%;
				height: 96rpx;
				background: #ff4a4a;
				border-radius: 80rpx;
				font-weight: bold;
				font-size: 36rpx;
				color: #ffffff;
				line-height: 96rpx;
			}
		}
	}
</style>